/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

app.controller('MainKeDesk', function($scope) {
    
    $scope.testing = "KeDesk v.1";
    console.log("loaded MainKeDesk");
});

app.controller('keLoadApps', function ($scope, KeDeskDataService) {
    
    KeDeskDataService.keDeskgetData('appItems').then(function(response) {
        $scope.data = response.data;
    });
    
});

app.controller('MainKeLabeling', function ($scope, KeDeskDataService) {
    
    $scope.appName = "KeLabeling";
    $scope.form = {};
    $scope.data = {};
    $scope.itemList = [];
    
    KeDeskDataService.keGetPrinters().then(function(response) {
            $scope.printers = response.data;
        });
        
    console.log("loaded MainKeLabeling");
    
    $scope.labelPrint = function(frmName, data) {
        
        KeDeskDataService.keProcessLabel(data).success(function(response) {
            $scope.clearForm(frmName);
        });
        
    };
    
    $scope.clearForm = function(frmName) {
        
        $scope.clearData = {};
        frmName.$setPristine();
        $scope.data = angular.copy($scope.clearData);
        $scope.itemList.splice(0);
    };
    
    $scope.addLabelItem = function(data) {
        
        $scope.itemList.push(data);
        $scope.data.ll = {};
        
    };
    
    $scope.removeLabelItem = function(index) {
        $scope.itemList.splice(index, 1);
    };
});